for slice_name in slice_names:
    ## 获取每一张轴状图的信息
    orienta, pos, pixelSpa  = df_study.loc[
        slice_name, ['orientation', "position", 'pixelSpacing',]].values.tolist()
    (r2, c2), o2, pixelSpa = parse_orentation(orienta), parse_position(pos), parse_pixelSpacing(pixelSpa)
    image = np.array(Image.open("data/images" + "/" + df_study.study.values[0] + "/" + slice_name.replace("dcm", "png")))
    srcHeigh, srcWidth = image.shape[:2]


    p1 = o2 # 左上角的点
    p2 = p1 + r2 * pixelSpa[0] * (srcWidth-1)  # 右上角的点
    p3 = p2 + c2 * pixelSpa[1] * (srcHeigh-1)  # 右下角的点
    p4 = p1 + c2 * pixelSpa[1] * (srcHeigh-1)  # 左下角的点
    # 点到平面的距离
    # p1 O1
    dv1 = np.dot(p1-o1, n1)
    # p2 O1
    dv2 = np.dot(p2-o1, n1)
    # p3 O1
    dv3 = np.dot(p3-o1, n1)
    # p4 O1
    dv4 = np.dot(p4-o1, n1)
    # 判断是否有交点
    iscross12 = ((dv1>0)&(dv2<0)) | ((dv1<0)&(dv2>0))
    iscross23 = ((dv2>0)&(dv3<0)) | ((dv2<0)&(dv3>0))
    iscross34 = ((dv3>0)&(dv4<0)) | ((dv3<0)&(dv4>0))
    iscross41 = ((dv4>0)&(dv1<0)) | ((dv4<0)&(dv1>0))
    if not(iscross12 | iscross23 | iscross34 | iscross41):
        continue
cps = []
    for iscross,(pv,pp),(ddv,ddp) in zip([iscross12, iscross23, iscross34, iscross41],
			    [(p1,p2),(p2,p3),(p3,p4),(p4,p1)], [(dv1,dv2),(dv2,dv3),(dv3,dv4),(dv4,dv1)]):
        if not iscross:
            # 是否相交
            continue
        # 计算交点坐标  相似三角形？
        cp = [pv[i] + (pp[i] - pv[i]) * ddv / (ddv - ddp) for i in range(3)]
	    cps.append(np.array(cp))
    for cp in cps:
        # 看下算出来的点在不在定位图平面上 带入平面方程 正确应该是几乎等于0
        print(n1 * (cp - o1))


    assert len(cps) == 2
    coords = []
    coords_img = []
    for cp in cps:
        # 投影
        xmap = np.dot(cp-o1, r1) / np.linalg.norm(r1)
        ymap = np.dot(cp-o1, c1) / np.linalg.norm(c1)

        # 这个没什么用
        coords.append(np.array(xmap, ymap))
        # pixel坐标
        coords_img.append(np.array([int(xmap/pixelSpacingXY[0]), int(ymap/pixelSpacingXY[1])]))

    if show:
        plt.plot((coords_img[0][0], coords_img[1][0]), (coords_img[0][1], coords_img[1][1]))
if show:
    plt.show()